    package com.itheima.service.mongo.impl;

    import com.itheima.domain.mongo.Movement;
    import com.itheima.service.db.ManageService;
    import org.apache.dubbo.config.annotation.DubboService;
    import org.bson.types.ObjectId;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.data.mongodb.core.MongoTemplate;
    import org.springframework.data.mongodb.core.query.Criteria;
    import org.springframework.data.mongodb.core.query.Query;
    import org.springframework.data.mongodb.core.query.Update;

    import java.util.ArrayList;
    import java.util.List;
    @DubboService
    public class ManageServiceImpl implements ManageService {
        @Autowired
        private MongoTemplate mongoTemplate;
        // 动态通过
        @Override
        public void pass(String[] ids) {
            List<ObjectId> list = new ArrayList<>();
            for (String id : ids) {
                ObjectId objectId = new ObjectId(id);
                list.add(objectId);
            }
            // 设置条件
            Criteria criteria = Criteria.where("id").in(list);
            Query query = Query.query(criteria);
            // 更改
            Update update = new Update();
            update.set("state", 1);
            mongoTemplate.updateMulti(query, update, Movement.class);
        }
        // 动态拒绝
        @Override
        public void reject(String[] ids) {
            List<ObjectId> list = new ArrayList<>();
            for (String id : ids) {
                ObjectId objectId = new ObjectId(id);
                list.add(objectId);
            }
            // 设置条件
            Criteria criteria = Criteria.where("id").in(list);
            Query query = Query.query(criteria);
            // 更改
            Update update = new Update();
            update.set("state", 2);
            mongoTemplate.updateMulti(query, update, Movement.class);
        }

    }
